package com.itheima.demo1creat;

public class ThreadDemo2
{
    public static void main(String[] args) {
        //用Runnable接口来创建线程任务
        MyRunnable r = new MyRunnable();
        //把线程任务对象交给线程对象来调用
        Thread t1 = new Thread(r);
        t1.start();
    }
}
//可以继续继承其他类和接口 扩展性强
class MyRunnable implements Runnable
{
    @Override
    public void run()
    {
        for (int i = 0; i < 10; i++)
        {
            System.out.println("线程1：" + i);
        }
    }
}
